/*
 * @Author: zhang zhijiang 2824735304@qq.com
 * @Date: 2025-03-24 20:49:11
 * @LastEditors: zhang zhijiang 2824735304@qq.com
 * @LastEditTime: 2025-03-24 22:14:17
 * @FilePath: /linux/test_3_24/main.cc
 * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
 */
#include"roundqueue.hpp"
#include<time.h>
void* consumer(void* argvs)
{
    roundqueue<int>* rq = static_cast<roundqueue<int>*>(argvs);
    sleep(6);

    while(1)
    {
     int data = rq->pop();
        cout<<"消费了一个数据...."<<data<<endl;
    }
}
void* productor(void* argvs)
{
    roundqueue<int>* rq = static_cast<roundqueue<int>*>(argvs);
    while(1)
    {
        int data = rand()%10+1;
      rq->push(data);
        cout<<"生产了一个数据:"<<data<<endl;
        sleep(1);
    }
}
int main()
{
    srand(time(nullptr));
    roundqueue<int>* rq = new roundqueue<int>() ; 
    pthread_t c,p;
    pthread_create(&c,nullptr,consumer,rq);
    pthread_create(&c,nullptr,productor,rq);
    pthread_join(c,nullptr);
    pthread_join(p,nullptr);
    return 0;
}